{% extends 'base.html' %}

{% block title %}{% if project.id %}编辑{% else %}新建{% endif %}项目 - 项目管理系统{% endblock %}

{% block content %}
<div class="card">
  <div class="card-header card-header-flex">
    <h5>{% if project.id %}编辑项目{% else %}新建项目{% endif %}</h5>
    <a href="{% if project.id %}{{ url_for('project_detail', project_id=project.id) }}{% else %}{{ url_for('project_list') }}{% endif %}" class="btn btn-secondary">
      <i class="fas fa-arrow-left"></i> 返回
    </a>
  </div>
  <div class="card-body">
    <form method="post" class="info-form">
      <div class="field-row">
        <label for="name">项目名称 <span class="text-danger">*</span></label>
        <div class="field-content">
          <i class="fas fa-project-diagram icon"></i>
          <input type="text" class="form-control" id="name" name="name" value="{{ project.name }}" required>
        </div>
      </div>
      
      <div class="field-row">
        <label for="code">项目代码 <span class="text-danger">*</span></label>
        <div class="field-content">
          <i class="fas fa-code icon"></i>
          <input type="text" class="form-control" id="code" name="code" value="{{ project.code }}" required>
        </div>
      </div>
      
      <div class="field-row">
        <label for="category_id">项目分类 <span class="text-danger">*</span></label>
        <div class="field-content">
          <i class="fas fa-tags icon"></i>
          <select class="form-control" id="category_id" name="category_id" required>
            {% for category in categories %}
            <option value="{{ category.id }}" {% if category.id == project.category_id %}selected{% endif %}>{{ category.name }}</option>
            {% endfor %}
          </select>
        </div>
      </div>
      
      <div class="field-row">
        <label for="status_id">项目状态 <span class="text-danger">*</span></label>
        <div class="field-content">
          <i class="fas fa-flag icon"></i>
          <select class="form-control" id="status_id" name="status_id" required>
            {% for status in statuses %}
            <option value="{{ status.id }}" {% if status.id == project.status_id %}selected{% endif %}>{{ status.name }}</option>
            {% endfor %}
          </select>
        </div>
      </div>
      
      <div class="field-row">
        <label for="git_url">GitLab源代码链接</label>
        <div class="field-content">
          <i class="fab fa-gitlab icon"></i>
          <input type="url" class="form-control" id="git_url" name="git_url" value="{{ project.git_url }}" placeholder="https://gitlab.com/your-project">
        </div>
      </div>
      
      <div class="field-row">
        <label for="description">项目描述</label>
        <div class="field-content">
          <i class="fas fa-comment-alt icon"></i>
          <textarea class="form-control" id="description" name="description" rows="5" placeholder="项目的详细描述...">{{ project.description }}</textarea>
        </div>
      </div>
      
      <div class="field-row mt-4">
        <label></label>
        <div class="field-content">
          <button type="submit" class="btn btn-primary">
            <i class="fas fa-save"></i> 保存
          </button>
          <a href="{% if project.id %}{{ url_for('project_detail', project_id=project.id) }}{% else %}{{ url_for('project_list') }}{% endif %}" class="btn btn-secondary ml-2">
            <i class="fas fa-times"></i> 取消
          </a>
        </div>
      </div>
    </form>
  </div>
</div>
{% endblock %} 